count and write the number of objects